package com.haitao.wavebbs.dao;

import com.haitao.wavebbs.entity.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface UserRepository extends CrudRepository<User,Integer> {
    /**
     * 根据用户账户查询用户详细信息。可用于用户登录验证
     * @param userAccount
     * @return
     */
    @Query(value = "select * from user where user_account= ?1",nativeQuery=true)
    User getUserByUserAccount(String userAccount);

    /**
     * 根据userId查询用户详细信息
     * @param userId
     * @return
     */
    @Query(value = "select * from user where user_id= ?1",nativeQuery=true)
    User getUserByUserId(int userId);
}
